package com.example.service.impl;

import ch.qos.logback.classic.Logger;
import com.example.entity.PointDefend;
import com.example.entity.SpotCheckPlan;
import com.example.mapp.PointFlowMapp;
import com.example.mapp.SpotCheckItemMapp;
import com.example.mapp.SpotCheckPlanMapp;
import com.example.mapp.SpotObjectPlanMapp;
import com.example.service.InformationAgentService;
import com.example.service.SpotCheckPlanService;
import com.example.util.DateUtils;
import com.example.util.ResultUtil;
import com.example.util.SystemPointUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 消息代办
 */
@Service
public class InformationAgentServiceImpl implements InformationAgentService {

	private final static Logger logger = (Logger) LoggerFactory.getLogger(InformationAgentServiceImpl.class);

	@Autowired
	private SpotCheckPlanMapp spotCheckPlanMapp;

	/**
	 * 获取消息代办
	 * @param map
	 * @return
	 */
	@Override
	public Map<String, Object> findList(Map map) {
		String message = "查询成功";
		List<Map<String, Object>> listParam = new ArrayList<>();
		try {
			if (map != null && map.size() > 0) {
				SpotCheckPlan plan = new SpotCheckPlan();
				plan.setStartTime(map.get("startTime").toString());
				plan.setIsCheck(map.get("isCheck").toString());
				List<SpotCheckPlan> list = spotCheckPlanMapp.findList(plan);
				if (list != null && list.size() > 0) {
					for (SpotCheckPlan checkPlan : list) {
						Map<String, Object> resultMap = new HashMap<>();
						resultMap.put("planName", checkPlan.getPlanName());
						resultMap.put("functionName", "维保检查计划");
						resultMap.put("addRessName", "/home/spot-check");
						resultMap.put("planStartTime", checkPlan.getPlanStartTime());
						resultMap.put("planEndTime", checkPlan.getPlanEndTime());
						listParam.add(resultMap);
					}
				}
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
			message = "查询失败";
			return ResultUtil.returnError(message + e.getMessage(), null);
		}
		return ResultUtil.returnSuccess(message, listParam);
	}
}
